package com.glory.nicleanrpt

import com.glory.njcleanrpt.DateUtil
import com.ivan.utils.PathUtil

/**
 * @Program: njcleanrpt
 * @Description: 受入不良统计表
 * @Author: ivan
 */
class InUnYieldTotalController {

    def dynamicQueryService

    def inUnYieldTotal() {
        request.setCharacterEncoding("UTF-8")
        response.setContentType("text/html;charset=UTF-8")
        def pageCurrent = params.pageCurrent ? Integer.parseInt(params.pageCurrent) : 1
        def pageSize = params.pageSize ? Integer.parseInt(params.pageSize) : 100
        params.startno = (pageSize * (pageCurrent - 1)) + 1
        params.endno = pageSize * pageCurrent
        def pageSizeList = [10, 20, 50, 100]
        params.startTime = DateUtil.getStartDate(params.startTime).startDate
        params.endTime = DateUtil.getEndDate(params.endTime).endDate
        def report_011 = []
        def tableHeadList = []
        def totalCount = 0
        def sysQueryName
        def sysQueryPath = PathUtil.getPath(this, request)
        if ('Excel'.equals(params.EXPORT_CONTENT_NAME)) {
            params.SYS_QUERY_NAME = 'inUnYieldTotalList'
            report_011 = dynamicQueryService.queryForList(params)
            if (report_011.size() > 0) {
                tableHeadList = report_011[0].keySet()
            }
            sysQueryName = params.SYS_QUERY_NAME
            params.SYS_QUERY_NAME = 'inUnYieldTotalCount'
            totalCount = dynamicQueryService.queryForList(params)[0].TOTALCOUNT
        }
        [
                pageCurrent   : pageCurrent,
                pageSize      : pageSize,
                pageSizeList  : pageSizeList,
                startno       : params.startno ?: '',
                endno         : params.endno ?: '',
                customName    : params.customName ?: '',
                deviceName    : params.deviceName ?: '',
                partName      : params.partName ?: '',
                markNum       : params.markNum ?: '',
                startTime     : params.startTime ?: '',
                endTime       : params.endTime ?: '',
                report_011    : report_011,
                totalCount    : totalCount,
                tableHeadList : tableHeadList,
                SYS_QUERY_PATH: sysQueryPath,
                SYS_QUERY_NAME: sysQueryName
        ]
    }
}